package br.com.materiais.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import br.com.materiais.dao.MateriaisDao;
import br.com.materiais.form.PesquisaMateriaisForm;
import br.com.materiais.model.MaterialModel;

public class PesquisaMateriaisAction extends Action 
{
	@SuppressWarnings("unchecked")
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			                    HttpServletRequest request, HttpServletResponse response) throws Exception 
   {
		PesquisaMateriaisForm pMateriais = ((PesquisaMateriaisForm)form);
		MaterialModel mMaterial = pMateriais.getPesquisar();
		List listMateriaisPesquisa = new MateriaisDao().getListaMateriais(mMaterial);
		
		request.setAttribute("pesquisaMaterial", listMateriaisPesquisa);
		
		return mapping.findForward("ok");
	}

}
